#pragma once

#include "Common.h"

// #define TIMER

#define MAX_TIMER_NAME 100

#define T_BIT_GENERATOR			0
#define T_DB_UNKNOWN			1
#define T_DB_SET_IMPOSSIBLE		2
#define T_DB_CAPTURES			3
#define T_DB_PASS_WHITE			4
#define T_DB_PASS_BLACK			5
#define T_DB_PROPAGATE_WHITE	6
#define T_DB_PROPAGATE_BLACK	7
#define T_DB_UNKNOWN_TO_DRAW	8
#define T_TEST_JUMP				9
#define T_FILE_READ				10
#define T_FILE_WRITE			11
#define T_MAX_TIMER				12


#define T_BIT_GENERATOR_NAME			L"BITBOARD_GEN"
#define T_DB_UNKNOWN_NAME				L"DB_UNKNOWN"
#define T_DB_SET_IMPOSSIBLE_NAME		L"SET_IMPOSSIBLE"
#define T_DB_CAPTURES_NAME				L"RESOLVE_CAPTURES"
#define T_DB_PASS_WHITE_NAME			L"IO_PASS_WHITE"
#define T_DB_PASS_BLACK_NAME			L"IO_PASS_BLACK"
#define T_DB_PROPAGATE_WHITE_NAME		L"PROPAGATE_WHITE"
#define T_DB_PROPAGATE_BLACK_NAME		L"PROPAGATE_BLACK"
#define T_DB_UNKNOWN_TO_DRAW_NAME		L"UNKNOWN_TO_DRAW"
#define T_FILE_READ_NAME				L"FILE_READ"
#define T_FILE_WRITE_NAME				L"FILE_WRITE"
#define T_TEST_JUMP_NAME				L"TEST_JUMP"

extern bool bPreciseMeasuring;

struct TimerRecord
{
	uint64 uiTotalTime;
	uint64 uiAverageTime;
	uint64 uiStartTime;
	uint64 iNumPasses;
	int iStartCallCount;
};


extern void (*TimerPrint)(wchar_t* szMessage);

void InitTimer();
void PrintTimerOutput();
void WatchStart(int type);
void WatchEnd(int type);
void LogTimerOutput(char *szFile);

#ifdef TIMER

#define WATCH_START(TYPE) WatchStart(TYPE);
#define WATCH_END(TYPE) WatchEnd(TYPE);

#else

#define WATCH_START(TYPE) ;
#define WATCH_END(TYPE)	;

#endif
